#include "info.h"
#include <iostream>
using namespace std;

int main()
{
    int total_students;
    cin >> total_students;

    studentlist newlist;

    for (int i = 0; i < total_students; i++)
    {
        student_node *student = new student_node;
        cin >> student->student_id;
        cin >> student->student_name;
        cin >> student->student_gender;
        cin >> student->exam_grade;
        newlist.add_student(student);
    }
    newlist.give_rank();
    int del_num;
    cin >> del_num;

    for (int i = 0; i < del_num; i++)
    {
        string command;
        int rank_to_del;
        cin >> command;

        if (command == "del")
        {
            cin >> rank_to_del;
        }

        newlist.del_student(rank_to_del);
    }

    newlist.print_list();

    return 0;
}